<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box1 {
            /*定义使用flex布局*/
            display: flex;
            /*垂直布局*/
            flex-direction: row;
            /*主轴居中*/
            justify-content: center;
            /*侧轴居中*/
            align-items: center;
            width: 300px;
            height: 300px;
            background-color: #999999;
        }

        .box1 div {
            width: 50px;
            height: 50px;
        }

        .box1 .div1 {
            background-color: yellow;
        }

        .box1 .div2 {
            background-color: coral;
            /*单独对div2设置，让它靠近顶部*/
            align-self: start;
        }

        .box1 .div3 {
            background-color: lightgreen;
        }
    </style>
</head>
<body>
<div class="box1">
    <div class="div1">1</div>
    <div class="div2">2</div>
    <div class="div3">3</div>
</div>
</body>
</html>